﻿//和CMS同一个进程（线程）里执行发布任务
//执行任务
var taskDataArray = new Array();
var taskData = new Object();
var ExecuteAddingShortTask = false; //正在执行添加任务
var SetWorksInterval = false;
var timer_task; //计时器
var _add_node_task = false; //添加结点任务
var node_task_dataArray = new Array();
function TaskRun_Ajax(url, id) {
    if (timer_task)
        clearInterval(timer_task);
    $.ajax({
        type: "POST",
        url: url,
        async: true,
        success: function (msg) {
            taskData = eval("taskData=" + msg);
            if (taskData.result == "1") {
                top.set_statewin_show(); //当执行任务时显示信息查看窗口
                node_task_dataArray.push(taskData);
                //TaskInfoShowBeginForIframe(taskData);
                if (_add_node_task == false) {
                    _add_node_task = true;
                    run_task();
                    //SetWorksInterval = true;
                    timer_task = setInterval("run_task();", 1000 * 5);
                }
            }
            else if (SetWorksInterval == false) {
                //timer_task = setInterval("run_task();", 1000 * 5);
            }

        }
    });
}
function TaskRun(url, id) {
    $.ajax({
        type: "POST",
        url: url,
        async: true,
        success: function (msg) {
            taskData = eval("taskData=" + msg);
            if (taskData.result == "1") {
                top.set_statewin_show(); //当执行任务时显示信息查看窗口
                taskDataArray.push(taskData);
                TaskInfoShowBeginForIframe(taskData);
                if (ExecuteAddingShortTask == false) {
                    ExecuteAddingShortTask = true;
                    bind();
                    SetWorksInterval = true;
                    setInterval("bind()", 1000 * 5);
                }
            }
            else if (SetWorksInterval == false) {
                setInterval("bind()", 1000 * 5);
            }

        }
    });
}
function TaskInfoShow(info, infoId) {//显示信息
    statewin.addInfo(info, infoId);
}
function TaskRemove(id) {
    $('#' + id).remove();
}
var sp_isRefash = false;
function window_onbeforeunload() {
    if (!sp_isRefash) {
        var str = "";
        str = "您如果关闭窗口，会导致您断开与服务器的连接，您的很多请求将不能实现，您真的要退出系统吗？";
        return str;
    }
}